home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / cshel401 / part01 next >
Encoding:
Internet Message Format  |  1990-03-13  |  56.2 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i103: CShell 4.01A - alternative command interface, Part01/04
  5. Message-ID: <11770@xanth.cs.odu.edu>
  6. Date: 13 Mar 90 00:44:59 GMT
  7. Sender: news@cs.odu.edu
  8. Reply-To: page@Eng.Sun.COM (Bob Page)
  9. Lines: 2261
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: page@Eng.Sun.COM (Bob Page)
  15. Posting-number: Volume 90, Issue 103
  16. Archive-name: unix/cshell-4.01a/part01
  17.  
  18. Shell provides a convient AmigaDos alternative command interface.  All
  19. its commands are internal and thus does not rely on the c: commands
  20. for any functionality.
  21.  
  22. New to 4.01A:
  23.  
  24. - This version features mostly bug fixes and corrections:
  25.  * Window title is restored after quitting.
  26.  * rxrec now answers to the 'bye' message.
  27.  * rpn can now be redirected and piped; however, this causes
  28.     some problem (see rpn for info).
  29.  * resident list now works with ARP 1.3. To recompile source, you must
  30.     modify include file "libraries/arpbase.h".
  31.     Change definition of rpn_Usage in struct ResidentProgramNode from LONG
  32.     to WORD.
  33.  * pri no more assumes 20 CLI maximum.
  34.  * you can now split long lines in source files even into more than 2 lines.
  35. - Added much info in this doc about source files (chapter XI)
  36. - Added copyright notice (see under restrictions).
  37.  
  38. #!/bin/sh
  39. # This is a shell archive.  Remove anything before this line, then unpack
  40. # it by saving it into a file and typing "sh file".  To overwrite existing
  41. # files, type "sh file -c".  You can also feed this as standard input via
  42. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  43. # will see the following message at the end:
  44. #        "End of archive 1 (of 4)."
  45. # Contents:  src src/comm3.c src/globals.c src/main.c src/makefile
  46. #   src/rawconsole.c src/run.c src/set.c src/shell.h
  47. #   src/shellfunctions.h
  48. # Wrapped by tadguy@xanth on Mon Mar 12 19:44:24 1990
  49. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  50. if test ! -d 'src' ; then
  51.     echo shar: Creating directory \"'src'\"
  52.     mkdir 'src'
  53. fi
  54. if test -f 'src/comm3.c' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'src/comm3.c'\"
  56. else
  57. echo shar: Extracting \"'src/comm3.c'\" \(12254 characters\)
  58. sed "s/^X//" >'src/comm3.c' <<'END_OF_FILE'
  59. X/*
  60. X * COMM3.C
  61. X *
  62. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  63. X *
  64. X */
  65. X
  66. Xdo_assign() {
  67. Xswitch(ac) {
  68. X    case 1:  assignlist();
  69. X         break;
  70. X    case 2:  doassign(av[1], NULL);
  71. X         break;
  72. X    case 3:  doassign(av[1], av[2]);
  73. X         break;
  74. X    default: ierror(NULL, 500);
  75. X         break;
  76. X    }
  77. Xreturn 0;
  78. X}
  79. X
  80. Xchar *assign_errors[4]={
  81. X    "",
  82. X    "Name %s is not valid\n",
  83. X    "Weird error\n",
  84. X    "Can't cancel %s\n"
  85. X    };
  86. X
  87. Xdoassign(log, phy)
  88. Xchar *log, *phy;
  89. X{
  90. Xint last=strlen(log) - 1;
  91. X
  92. Xif (log[last] != ':') fprintf(stderr, "Bad name %s\n", log);
  93. Xelse {
  94. X    log[last] = 0;
  95. X    fprintf(stderr,assign_errors[Assign(log, phy)],phy);
  96. X    }
  97. X}
  98. X
  99. Xassignlist()
  100. X{
  101. Xstruct DirectoryEntry *de_head=NULL, *de;
  102. Xchar buf[256];
  103. XBPTR lock;
  104. Xint ctr=0;
  105. X
  106. XAddDADevs(&de_head, DLF_DEVICES | DLF_VOLUMES | DLF_DIRS);
  107. Xprintf("Devices:\n");
  108. Xfor (de=de_head; de && de->de_Type==DLX_DEVICE; de=de->de_Next) {
  109. X    printf("%-8s",de->de_Name);
  110. X    if (ctr++ == 5) { ctr=0; printf("\n"); }
  111. X    }
  112. Xprintf("\n\nVolumes:\n");
  113. Xfor (    ;
  114. X    de && (de->de_Type==DLX_VOLUME || de->de_Type==DLX_UNMOUNTED);
  115. X    de=de->de_Next
  116. X    )
  117. X    printf( "%-16s %s\n",
  118. X        de->de_Name,
  119. X        de->de_Type == DLX_VOLUME ? "[Mounted]" : ""
  120. X        );
  121. Xprintf("\nDirectories:\n");
  122. Xfor (; de && de->de_Type==DLX_ASSIGN; de=de->de_Next) {
  123. X    if (lock=Lock(de->de_Name, ACCESS_READ)) {
  124. X        PathName(lock, buf, 256L);
  125. X        UnLock(lock);
  126. X        }
  127. X    else
  128. X        strcpy(buf,"Unexisting lock");
  129. X    printf("%-20s%s\n",de->de_Name,buf);
  130. X    }
  131. XFreeDAList(&de_head);
  132. X}
  133. X
  134. Xdo_join()
  135. X{
  136. XBPTR sou, dest;
  137. Xchar *buffer;
  138. Xunsigned int i;
  139. Xlong n;
  140. Xchar *namedest=av[--ac];
  141. X
  142. Xget_opt("r", &i);
  143. Xif (options==0 && exists(namedest)) { ierror(namedest,203); return 20; }
  144. Xif ( (buffer=malloc(8192)) == NULL ) { ierror(NULL,103); return 20; }
  145. Xif ( (dest=Open(namedest, MODE_NEWFILE)) == NULL )
  146. X    { pError(namedest); goto fail1; }
  147. Xfor (i=1; i<ac; i++) {
  148. X    if ( (sou=Open(av[i], MODE_OLDFILE)) == NULL ) pError(av[i]);
  149. X    else
  150. X        while( (n=Read(sou, buffer, 8192L)) > 0 )
  151. X            if (Write(dest, buffer, n) != n)
  152. X                { pError(namedest); Close(sou); goto fail2; }
  153. X    Close(sou);
  154. X    }
  155. Xfail2:
  156. X    Close(dest);
  157. Xfail1:
  158. X    free(buffer);
  159. X    return 0;
  160. X}
  161. X
  162. X#define BUFDIM 512L
  163. X#define MAXSTR 256
  164. X
  165. Xint minstr;
  166. X
  167. Xstrings_in_file(s)
  168. Xchar *s;
  169. X{
  170. Xchar c;
  171. Xchar readbuf[BUFDIM+1], strbuf[MAXSTR+1];
  172. Xregister unsigned int i, strctr=0;
  173. XBPTR fh;
  174. Xint out, n;
  175. X
  176. Xif ( fh=Open(s, MODE_OLDFILE) ) {
  177. X    fprintf(stderr, "Strings in %s (len>=%d):\n",s,minstr);
  178. X    while ( (n=(int)Read(fh, readbuf, BUFDIM)) > 0 && !CHECKBREAK() )
  179. X        for (i=0; i<n; i++) {
  180. X        c=readbuf[i];
  181. X        if (c<0x20 || c>0x7f) {
  182. X            out=(strctr>=minstr);
  183. X            if (!out) strctr=0;
  184. X            }
  185. X        else {
  186. X            strbuf[strctr++]=c;
  187. X            out=(strctr>=BUFDIM);
  188. X            }
  189. X        if (out) {
  190. X            strbuf[strctr]='\0';
  191. X            puts(strbuf);
  192. X            strctr=0;
  193. X            }
  194. X        }
  195. X    Close(fh);
  196. X    }
  197. Xelse pError(s);
  198. X}
  199. X
  200. Xdo_strings()
  201. X{
  202. Xminstr=myatoi(av[--ac],1,255);
  203. Xall_args("r", strings_in_file, 0);
  204. Xreturn 0;
  205. X}
  206. X
  207. XBPTR myfile[MAXMYFILES];
  208. X
  209. Xdo_open()
  210. X{
  211. Xlong mode;
  212. Xunsigned int n;
  213. X
  214. Xswitch (toupper(av[2][0])) {
  215. X    case 'R': mode=MODE_OLDFILE; break;
  216. X    case 'W': mode=MODE_NEWFILE; break;
  217. X    default : ierror(NULL,500); return;
  218. X    }
  219. Xn=(unsigned int)myatoi(av[3],0,MAXMYFILES-1); if (atoierr) return 20;
  220. Xif (myfile[n]) myclose(n);
  221. Xmyfile[n]=Open(av[1],mode);
  222. Xreturn (myfile[n]==NULL);
  223. X}
  224. X
  225. Xdo_close()
  226. X{
  227. Xregister unsigned int i;
  228. Xint n;
  229. X
  230. Xif (ac==1)
  231. X    for (i=1; i<MAXMYFILES; i++)
  232. X        myclose(i);
  233. Xfor (i=1; i<ac; i++) {
  234. X    n=myatoi(av[i],0,MAXMYFILES-1); if (atoierr) return 20;
  235. X    myclose(n);
  236. X    }
  237. Xreturn 0;
  238. X}
  239. X
  240. Xmyclose(n)
  241. X{
  242. Xif (myfile[n]) { Close(myfile[n]); myfile[n]=NULL; }
  243. X}
  244. X
  245. Xdo_fileslist()
  246. X{
  247. Xregister unsigned short i;
  248. Xint flag=0;
  249. X
  250. Xprintf("Open files:");
  251. Xfor (i=0; i<MAXMYFILES; i++)
  252. X    if (myfile[i]) { printf(" %d",i); flag=1; }
  253. Xif (!flag) printf(" None!");
  254. Xprintf("\n");
  255. Xreturn 0;
  256. X}
  257. X
  258. XBPTR extOpen(name,mode)
  259. Xchar *name;
  260. Xlong mode;
  261. X{
  262. Xif (name[0]=='.') return myfile[atoi(name+1)];
  263. Xreturn Open(name,mode);
  264. X}
  265. X
  266. XextClose(fh)
  267. XBPTR fh;
  268. X{
  269. Xregister unsigned short i;
  270. X
  271. Xfor (i=0; i<MAXMYFILES; i++)
  272. X    if (myfile[i]==fh) return;
  273. XClose(fh);
  274. X}
  275. X
  276. Xdo_basename()
  277. X{
  278. Xset_var(LEVEL_SET, av[1], BaseName(av[2]));
  279. Xreturn 0;
  280. X}
  281. X
  282. Xdo_tackon()
  283. X{
  284. Xchar buf[256];
  285. X
  286. Xstrcpy(buf, av[2]);
  287. XTackOn(buf, av[3]);
  288. Xset_var(LEVEL_SET, av[1], buf);
  289. Xreturn 0;
  290. X}
  291. X
  292. Xdo_resident()
  293. X{
  294. Xunsigned int i;
  295. Xregister struct ResidentProgramNode *p;
  296. Xchar buf[256];
  297. X
  298. Xget_opt("ard", &i);
  299. Xif (options==0 && ac>1) options=1;
  300. Xswitch (options) {
  301. X    case 0:
  302. X    ObtainSemaphore (& (ArpBase->ResPrgProtection) );
  303. X    if (p=ArpBase->ResidentPrgList) {
  304. X        printf("Name             Users Access\n");
  305. X        for (; p; p=p->rpn_Next)
  306. X            printf("%-17s%5d%6d\n",
  307. X                p->rpn_Name, p->rpn_Usage, p->rpn_AccessCnt);
  308. X        }
  309. X    else printf("No resident program(s)\n");
  310. X    ReleaseSemaphore(& (ArpBase->ResPrgProtection) );
  311. X    break;
  312. X    case 1:
  313. X    for (; i<ac; i++)
  314. X        if (loadres(av[i]))
  315. X            printf("OK! %s is now resident\n", BaseName(av[i]));
  316. X        else pError(av[i]);
  317. X    break;
  318. X    case 2:
  319. X    for (; i<ac; i++)
  320. X        if (RemResidentPrg(av[i])) ierror(av[i],202);
  321. X        else printf("Removed %s\n",av[i]);
  322. X    break;
  323. X    case 4:
  324. X    for (; i<ac; i++) {
  325. X        sprintf(buf,"res_%s",av[i]);
  326. X        Setenv(buf,"1");
  327. X        }
  328. X    break;
  329. X    default:
  330. X    ierror(NULL,500);
  331. X    break;
  332. X    }
  333. Xreturn 0;
  334. X}
  335. X
  336. Xint loadres(s)
  337. Xchar *s;
  338. X{
  339. XBPTR seg;
  340. X
  341. Xif (seg=(BPTR)LoadPrg(s)) AddResidentPrg(seg,BaseName(s));
  342. Xreturn (seg != NULL);
  343. X}
  344. X
  345. Xstruct ProcessControlBlock pcb={
  346. X    4000,        /* pcb_StackSize    */
  347. X    0,        /* pcb_Pri        */
  348. X    };
  349. X/* remaining field are NULL */
  350. X    
  351. Xdo_truerun(avline, backflag)
  352. Xchar *avline;
  353. X{
  354. Xchar name[200];
  355. Xchar *FindIt();
  356. X
  357. Xif (backflag) {
  358. X    pcb.pcb_Control=NULL;
  359. X    pcb.pcb_Input=pcb.pcb_Output=Open("NIL:",MODE_OLDFILE);
  360. X    }
  361. Xelse {
  362. X    pcb.pcb_Control=NULL;
  363. X    pcb.pcb_Input=pcb.pcb_Output =NULL;
  364. X    }
  365. Xif (FindIt(av[1], "", name))
  366. X    ASyncRun(name,next_word(next_word(avline)),&pcb);
  367. Xelse
  368. X    ierror(av[1],205);
  369. Xreturn 0;
  370. X}
  371. X
  372. Xint exists(name)
  373. Xchar *name;
  374. X{
  375. XBPTR lock;
  376. X
  377. Xif (lock=Lock(name,ACCESS_READ)) {
  378. X    UnLock(lock);
  379. X    return 1;
  380. X    }
  381. Xreturn 0;
  382. X}
  383. X
  384. Xdo_aset()
  385. X{
  386. XSetenv(av[1],av[2]);
  387. Xreturn 0;
  388. X}
  389. X
  390. X#define HTYPELINE 16L
  391. X
  392. Xhtype_a_file(s)
  393. Xchar *s;
  394. X{
  395. XBPTR fh;
  396. Xlong n, filesize=0;
  397. Xchar buf[HTYPELINE+1];
  398. Xregister unsigned short i;
  399. X
  400. Xif ( (fh=Open(s,MODE_OLDFILE))==NULL ) { pError(s); return 20; }
  401. Xwhile ( (n=Read(fh,buf,HTYPELINE))>0 && !dobreak()) {
  402. X    printf("%06lx: ",filesize);
  403. X    filesize+=n;
  404. X    for (i=0; i<n; i++) {
  405. X        printf( (i&3) ? "%02x" : " %02x",(int)(unsigned char)buf[i]);
  406. X        if (buf[i]<0x20) buf[i]='.';
  407. X        }
  408. X    for ( ; i<HTYPELINE; i++) {
  409. X        printf( (i&3) ? "  " : "   ");
  410. X        buf[i]=' ';
  411. X        }
  412. X    buf[i]=0;
  413. X    printf("    %s\n",buf);
  414. X    }
  415. XClose(fh);
  416. Xreturn 0;
  417. X}
  418. X
  419. Xdo_htype()
  420. X{
  421. Xall_args("", htype_a_file, 0);
  422. Xreturn 0;
  423. X}
  424. X
  425. Xdo_stack()
  426. X{
  427. Xlong n;
  428. X
  429. Xif (ac>1) {
  430. X    n=Atol(av[1]);
  431. X    if (!IoErr()) Mycli->cli_DefaultStack=(long)(n >> 2L);
  432. X    }
  433. Xelse printf("current stack size is %ld bytes\n",
  434. X                (long)Mycli->cli_DefaultStack << 2L);
  435. Xreturn 0;
  436. X}
  437. X
  438. Xdo_fault()
  439. X{
  440. Xstruct PERROR *p;
  441. Xregister unsigned int i;
  442. Xint n;
  443. X
  444. Xfor (i=1; i<ac; i++) {
  445. X    n=myatoi(av[i],0,32767);
  446. X    if (!atoierr) {
  447. X        for (p=Perror; p->errnum && p->errnum!=n; p++);
  448. X        if (p->errnum)
  449. X            printf("Fault %d: %s\n",n,p->errstr);
  450. X        else
  451. X            printf("Fault %d not recognized\n",n);
  452. X        }
  453. X    }
  454. Xreturn 0;
  455. X}
  456. X
  457. Xstruct rpncommand {
  458. X    char *str;
  459. X    int parsin, parsout;
  460. X    };
  461. X
  462. Xstruct rpncommand rpn[]={
  463. X    "+",    2,    1,
  464. X    "-",    2,    1,
  465. X    "*",    2,    1,
  466. X    "/",    2,    1,
  467. X    "%",    2,    1,
  468. X    "&",    2,    1,
  469. X    "|",    2,    1,
  470. X    "~",    1,    1,
  471. X    ">",    2,    1,
  472. X    "<",    2,    1,
  473. X    "==",    2,    1,
  474. X    "!",    1,    1,
  475. X    "DUP",    1,    2,
  476. X    "DROP",    1,    0,
  477. X    "SWAP",    2,    2,
  478. X    "HELP",    0,    0,
  479. X    NULL,    0,    1,    /* this looks for a number */
  480. X};
  481. X
  482. Xdo_rpn(garbage,ifflag) /* ifflag!=0 if called from if */
  483. Xchar *garbage;
  484. X{
  485. Xregister long n0, n1;
  486. Xlong t;
  487. Xunsigned int i, j;
  488. Xint sp=0;
  489. Xlong stack[100];
  490. Xstruct rpncommand *temp;
  491. X
  492. Xi=1;
  493. Xif (ifflag) get_opt("rn",&i);
  494. Xfor (; i<ac; i++) {
  495. X    for (j=0; rpn[j].str && Strcmp(rpn[j].str,av[i]); j++) ;
  496. X    n0=stack[sp-1];
  497. X    n1=stack[sp-2];
  498. X    sp -= (rpn[j].parsin);
  499. X    if (sp<0) { fprintf(stderr, "RPN: Empty stack\n"); return 1; }
  500. X    switch (j) {
  501. X      case 0:    n0 += n1;        break;
  502. X      case 1:    n0 = n1-n0;        break;
  503. X      case 2:    n0 *= n1;        break;
  504. X      case 3:    n0 = n1/n0;        break;
  505. X      case 4:    n0 = n1%n0;        break;
  506. X      case 5:    n0 &= n1;        break;
  507. X      case 6:    n0 |= n1;        break;
  508. X      case 7:    n0 =  ~n0;        break;
  509. X      case 8:    n0 = (n1 > n0);        break;
  510. X      case 9:    n0 = (n1 < n0);        break;
  511. X      case 10:    n0 = (n0 == n1);    break;
  512. X      case 11:    n0 = !n0;        break;
  513. X      case 12:    n1=n0;            break;
  514. X      case 13:    t=n0; n0=n1; n1=t;    break;
  515. X      case 14:                break;
  516. X      case 15:    printf("In Commands Out\n");
  517. X            for (temp=rpn; temp->str; temp++)
  518. X                printf(" %d %-10s%d\n",
  519. X                temp->parsin,temp->str,temp->parsout);
  520. X            break;
  521. X      default:    n0=Atol(av[i]);
  522. X            if (IoErr()) {
  523. X                fprintf(stderr, "Bad RPN cmd: %s\n",av[i]);
  524. X                return 20;
  525. X                }
  526. X            break;
  527. X      }
  528. X    stack[sp]=n0;
  529. X    stack[sp+1]=n1;
  530. X    sp += rpn[j].parsout;
  531. X    }
  532. Xif (ifflag) return (int)(stack[sp-1]);    /* called from if: return top value */
  533. Xfor (i=sp-1;(int)i>=0;i--) printf("%ld\n", stack[i]); /* else print stack */
  534. Xreturn 0;
  535. X}
  536. X
  537. Xdo_path()
  538. X{
  539. Xunion {    long *lp; long ll; } l;
  540. Xchar buf[256];
  541. X
  542. Xputs("Current dir");
  543. Xl.lp = (long *) Mycli->cli_CommandDir;
  544. Xwhile (l.ll) {
  545. X    l.ll <<= 2;
  546. X    PathName(l.lp[1], buf, 256L);
  547. X    puts(buf);
  548. X    l.ll = *l.lp;
  549. X    }
  550. Xputs("C:");
  551. Xreturn 0;
  552. X}
  553. X
  554. Xdo_pri()
  555. X{
  556. Xint t, pri;
  557. Xstruct Process *proc;
  558. X
  559. Xt=(int)(long)FindCLI(0L);
  560. Xt=myatoi(av[1],0,t); if (atoierr) return 20;
  561. Xpri=myatoi(av[2],-128,127); if (atoierr) return 20;
  562. XForbid();
  563. Xproc=(t==0 ? Myprocess : FindCLI((long)t));
  564. Xif (proc==NULL) fprintf(stderr, "process not found\n");
  565. X    else SetTaskPri(proc, (long)pri);
  566. XPermit();
  567. Xreturn 0;
  568. X}
  569. X
  570. Xdo_strleft()
  571. X{
  572. Xchar buf[256];
  573. Xint n;
  574. X
  575. Xstrcpy(buf,av[2]);
  576. Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20;
  577. Xbuf[n]='\0';
  578. Xset_var(LEVEL_SET, av[1], buf);
  579. Xreturn 0;
  580. X}
  581. X
  582. Xdo_strright()
  583. X{
  584. Xchar buf[256];
  585. Xint n;
  586. X
  587. Xstrcpy(buf, av[2]);
  588. Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20;
  589. Xset_var(LEVEL_SET, av[1], buf+strlen(buf)-n);
  590. Xreturn 0;
  591. X}
  592. X
  593. Xdo_strmid()
  594. X{
  595. Xchar buf[256];
  596. Xint n1, n2;
  597. X
  598. Xstrcpy(buf, av[2]);
  599. Xn1=myatoi(av[3],1,strlen(buf))-1; if (atoierr) return 20;
  600. Xif (ac>4) {
  601. X    n2=myatoi(av[4],1,strlen(buf)-n1); if (atoierr) return 20;
  602. X    buf[n1+n2]='\0';
  603. X    }
  604. Xset_var(LEVEL_SET, av[1], buf+n1);
  605. Xreturn 0;
  606. X}
  607. X
  608. Xdo_strlen()
  609. X{
  610. Xchar buf[16];
  611. X
  612. Xsprintf(buf,"%d",strlen(av[2]));
  613. Xset_var(LEVEL_SET, av[1], buf);
  614. Xreturn 0;
  615. X}
  616. X
  617. Xint atoierr;
  618. X
  619. Xmyatoi(s,min,max)
  620. Xchar *s;
  621. X{
  622. Xint n;
  623. X
  624. Xn=(int)(long)Atol(s);
  625. Xif (atoierr=IoErr())
  626. X    ierror(s,511);
  627. X    else if (n<min || n>max) {
  628. X        atoierr=1;
  629. X        printf("%s(%d) not in (%d,%d)\n",s,n,min,max);
  630. X        }
  631. Xreturn n;
  632. X}
  633. X
  634. Xdo_fltlower()
  635. X{
  636. Xchar buf[256], *s;
  637. X
  638. Xwhile (!CHECKBREAK() && gets(buf)) {
  639. X    for (s=buf; *s; s++) *s=tolower(*s);
  640. X    puts(buf);
  641. X    }
  642. Xreturn 0;
  643. X}
  644. X
  645. Xdo_fltupper()
  646. X{
  647. Xchar buf[256], *s;
  648. X
  649. Xwhile (!CHECKBREAK() && gets(buf)) {
  650. X    for (s=buf; *s; s++) *s=toupper(*s);
  651. X    puts(buf);
  652. X    }
  653. Xreturn 0;
  654. X}
  655. X
  656. X#define RXFB_RESULT  17
  657. X
  658. Xstatic struct rexxmsg {
  659. X    struct Message cm_Node;
  660. X    LONG   RFU1;
  661. X    LONG   RFU2;
  662. X    LONG   rm_Action;
  663. X    LONG   rm_Result1;
  664. X    LONG   rm_Result2;
  665. X    char   *cm_Args[16];
  666. X    LONG   RFU7;
  667. X    LONG   RFU8;
  668. X    LONG   RFU9;
  669. X    LONG   RFU10;
  670. X    LONG   RFU11;
  671. X    LONG   RFU12;
  672. X} mymsg;
  673. X
  674. Xdo_rxsend()
  675. X{
  676. Xint i=1, resflag;
  677. Xchar *result;
  678. Xstruct MsgPort *port, *reply;
  679. Xlong len;
  680. X
  681. Xget_opt("r", &i);
  682. Xresflag=options;
  683. Xif (!(port = FindPort(av[i++]))) { fprintf(stderr, "No port %s!\n", av[--i]); return 20; }
  684. Xmymsg.cm_Node.mn_Node.ln_Type = NT_MESSAGE;
  685. Xmymsg.cm_Node.mn_Length = sizeof(struct rexxmsg);
  686. Xmymsg.rm_Action = (resflag ? 1L << RXFB_RESULT : 0);
  687. Xif (!(reply = CreatePort(NULL, 0L))) {
  688. X    fprintf(stderr, "No reply port\n");
  689. X    return 20;
  690. X    }
  691. Xmymsg.cm_Node.mn_ReplyPort = reply;
  692. X
  693. Xfor ( ; i<ac; i++) {
  694. X    mymsg.cm_Args[0] = av[i];
  695. X    mymsg.rm_Result2 = 0;    /* clear out the last result. */
  696. X    PutMsg(port, &mymsg.cm_Node);
  697. X    WaitPort(reply);
  698. X
  699. X    if (resflag) {
  700. X        result=(char *)mymsg.rm_Result2;
  701. X        len=*( (long *)(result-4) );
  702. X        if (len<0 || len>256)
  703. X            fprintf(stderr, "Risultato troppo lungo\n");
  704. X        else
  705. X            printf("%s\n", result);
  706. X        FreeMem(result, len);
  707. X        }
  708. X    }
  709. X
  710. Xif (reply) DeletePort(reply);
  711. Xreturn 0;
  712. X}
  713. X
  714. Xdo_rxrec()
  715. X{
  716. Xstruct MsgPort *port;
  717. Xstruct rexxmsg *msg;
  718. Xchar *portname, *str;
  719. X
  720. Xif (ac > 1)
  721. X    portname=av[1];
  722. Xelse
  723. X    portname="rexx_csh";
  724. X
  725. Xport=CreatePort(portname, 0L);
  726. Xif (port==NULL) {
  727. X    fprintf(stderr, "Can't have MsgPort %s\n", portname);
  728. X    return 20;
  729. X    }
  730. Xfor (;;) {
  731. X    WaitPort(port);
  732. X    while (msg=(struct rexxmsg *)GetMsg(port)) {
  733. X        if ( ! Strcmp(msg->cm_Args[0], "bye")) {
  734. X            ReplyMsg((struct Message *)msg);
  735. X            DeletePort(port);
  736. X            return 0;
  737. X            }
  738. X        exec_command(msg->cm_Args[0]);
  739. X        if (msg->rm_Action & (1L << RXFB_RESULT)) {
  740. X            str = get_var(LEVEL_SET, v_lasterr);
  741. X            msg->rm_Result2=(str) ? atoi(str) : 20;
  742. X            }
  743. X        ReplyMsg((struct Message *)msg);
  744. X        }
  745. X    }
  746. X}
  747. END_OF_FILE
  748. if test 12254 -ne `wc -c <'src/comm3.c'`; then
  749.     echo shar: \"'src/comm3.c'\" unpacked with wrong size!
  750. fi
  751. # end of 'src/comm3.c'
  752. fi
  753. if test -f 'src/globals.c' -a "${1}" != "-c" ; then 
  754.   echo shar: Will not clobber existing file \"'src/globals.c'\"
  755. else
  756. echo shar: Extracting \"'src/globals.c'\" \(3551 characters\)
  757. sed "s/^X//" >'src/globals.c' <<'END_OF_FILE'
  758. X
  759. X/*
  760. X * GLOBALS.C
  761. X *
  762. X * (c)1986 Matthew Dillon     9 October 1986
  763. X *
  764. X * Version 2.07M by Steve Drew 10-Sep-87
  765. X *
  766. X *    Most global variables.
  767. X *
  768. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  769. X *
  770. X */
  771. X
  772. Xchar v_titlebar    []="_titlebar";    /* Window title                */
  773. Xchar v_prompt    []="_prompt";    /* your prompt (ascii command)        */
  774. Xchar v_hist    []="_history";    /* set history depth (value)        */
  775. Xchar v_histnum    []="_histnum";    /* set history numbering var        */
  776. Xchar v_debug    []="_debug";    /* set debug mode            */
  777. Xchar v_verbose    []="_verbose";    /* set verbose for source files        */
  778. Xchar v_stat    []="_maxerr";    /* worst return value to date        */
  779. Xchar v_lasterr    []="_lasterr";    /* return value from last comm.        */
  780. Xchar v_cwd    []="_cwd";    /* current directory            */
  781. Xchar v_except    []="_except";    /* "nnn;command"            */
  782. Xchar v_passed    []="_passed";    /* passed arguments to source file    */
  783. Xchar v_path    []="_path";    /* search path for external commands    */
  784. Xchar v_gotofwd    []="_gtf";    /* set name for fwd goto name        */
  785. Xchar v_linenum    []="_linenum";    /* name for forline line #        */
  786. X
  787. Xstruct HIST *H_head, *H_tail;    /* HISTORY lists */
  788. X
  789. Xstruct PERROR Perror[]= {    /* error code->string */
  790. X    103,    "Insufficient free storage",
  791. X    105,    "Task table full",
  792. X    120,    "Argument line invalid or too long",
  793. X    121,    "File is not an object module",
  794. X    122,    "Invalid resident library during load",
  795. X    201,    "No default directory",
  796. X    202,    "Object in use",
  797. X    203,    "Object already exists",
  798. X    204,    "Directory not found",
  799. X    205,    "Object not found",
  800. X    206,    "Bad stream name",
  801. X    207,    "Object too large",
  802. X    209,    "Action not known",
  803. X    210,    "Invalid stream component name",
  804. X    211,    "Invalid object lock",
  805. X    212,    "Object not of required type",
  806. X    213,    "Disk not validated",
  807. X    214,    "Disk write protected",
  808. X    215,    "Rename across devices",
  809. X    216,    "Directory not empty",
  810. X    217,    "Too many levels",
  811. X    218,    "Device not mounted",
  812. X    219,    "Seek error",
  813. X    220,    "Comment too long",
  814. X    221,    "Disk full",
  815. X    222,    "File delete protected",
  816. X    223,    "File write protected",
  817. X    224,    "File read protected",
  818. X    225,    "Not a DOS disk",
  819. X    226,    "No disk",
  820. X
  821. X /* custom error messages */
  822. X
  823. X    500,    "Bad arguments",
  824. X    501,    "Label not found",
  825. X    502,    "Must be within source file",
  826. X    503,    "Syntax Error",
  827. X    504,    "Redirection error",
  828. X    505,    "Pipe error",
  829. X    506,    "Too many arguments",
  830. X    507,    "Destination not a directory",
  831. X    508,    "Cannot mv a filesystem",
  832. X    509,    "Error in command name",
  833. X    510,    "Bad drive name",
  834. X    511,    "Illegal number",
  835. X    0,    NULL
  836. X};
  837. X
  838. Xchar *av[MAXAV];        /* Internal argument list        */
  839. Xlong Src_base[MAXSRC];        /* file pointers for source files    */
  840. Xlong Src_pos[MAXSRC];        /* seek position storage for same    */
  841. Xchar If_base[MAXIF];        /* If/Else stack for conditionals    */
  842. Xint H_len, H_tail_base;        /* History associated stuff        */
  843. Xint H_stack;            /* AddHistory disable stack        */
  844. Xint E_stack;            /* Exception disable stack        */
  845. Xint Src_stack, If_stack;    /* Stack Indexes            */
  846. Xint forward_goto;        /* Flag for searching for foward lables    */
  847. Xint ac;                /* Internal argc            */
  848. Xint debug;            /* Debug mode                */
  849. Xint disable;            /* Disable com. execution (conditionals)*/
  850. Xint Verbose;            /* Verbose mode for source files    */
  851. Xint Lastresult;            /* Last return code            */
  852. Xint Exec_abortline;        /* flag to abort rest of line        */
  853. Xint Quit;            /* Quit flag                */
  854. Xlong Cout, Cin;            /* Current input and output file handles*/
  855. Xlong Cout_append;        /* append flag for Cout            */
  856. Xchar *Cin_name, *Cout_name;    /* redirection input/output name or NULL*/
  857. Xchar *Pipe1, *Pipe2;        /* the two pipe temp. files        */
  858. Xstruct Process *Myprocess;
  859. Xstruct CommandLineInterface *Mycli;
  860. Xint S_histlen = 20;        /* Max # history entries        */
  861. Xunsigned int options;
  862. END_OF_FILE
  863. if test 3551 -ne `wc -c <'src/globals.c'`; then
  864.     echo shar: \"'src/globals.c'\" unpacked with wrong size!
  865. fi
  866. # end of 'src/globals.c'
  867. fi
  868. if test -f 'src/main.c' -a "${1}" != "-c" ; then 
  869.   echo shar: Will not clobber existing file \"'src/main.c'\"
  870. else
  871. echo shar: Extracting \"'src/main.c'\" \(4978 characters\)
  872. sed "s/^X//" >'src/main.c' <<'END_OF_FILE'
  873. X/*
  874. X * MAIN.C
  875. X *
  876. X * Matthew Dillon, 24 Feb 1986
  877. X * (c)1986 Matthew Dillon     9 October 1986
  878. X *
  879. X * Version 2.07M by Steve Drew 10-Sep-87
  880. X *
  881. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  882. X *
  883. X */
  884. X
  885. Xchar shellname[]="Shell V4.01A";
  886. Xchar shellctr []="CshCounter";
  887. X
  888. Xint aux; /* for use with aux: driver */
  889. Xchar *oldtitle;
  890. Xchar trueprompt[100];
  891. Xchar Inline[260];
  892. Xstruct IntuitionBase *IntuitionBase;
  893. Xstruct Window *w;
  894. Xstruct ArpBase *ArpBase;
  895. X
  896. Xmain(argc, argv)
  897. Xregister char *argv[];
  898. X{
  899. X#if RAW_CONSOLE
  900. X    char *rawgets();
  901. X#endif
  902. X
  903. Xregister unsigned int i;
  904. Xextern int Enable_Abort;
  905. Xchar buf[10];
  906. Xstatic char pipe1[32], pipe2[32];
  907. Xstruct Window *getwindow();
  908. X
  909. XArpBase=(struct ArpBase *)OpenLibrary("arp.library",34L);
  910. Xif (ArpBase==NULL) { printf("No arp library\n"); exit(0); }
  911. X
  912. XForbid();
  913. Xi=0;
  914. Xif (Getenv(shellctr,buf,10L)) {
  915. X    i=(int)(long)Atol(buf);
  916. X    if (IoErr()) i=0;
  917. X    }
  918. Xsprintf(buf,"%d",i+1);
  919. XSetenv(shellctr,buf);
  920. XPermit();
  921. X
  922. XIntuitionBase=(struct IntuitionBase *)ArpBase->IntuiBase;
  923. X
  924. Xstdin->_flags    |= 0x80;    /* make sure we're set as a tty */
  925. Xstdout->_flags    |= 0x80;    /* in case of redirection in .login */
  926. XClose(_devtab[2].fd);
  927. X_devtab[2].mode |= O_STDIO;
  928. X_devtab[2].fd = _devtab[1].fd;    /* set stderr to Output() otherwise */
  929. X                /* don't work with aux driver */
  930. XMyprocess = (struct Process *)FindTask(0L);
  931. XMycli=(struct CommandLineInterface *)((long)Myprocess->pr_CLI << 2);
  932. Xw=getwindow();
  933. X
  934. Xoldtitle=(char *)(w->Title);
  935. X
  936. XPipe1 = pipe1;
  937. XPipe2 = pipe2;
  938. Xsprintf(pipe1, "ram:pipe1_%ld", Myprocess);
  939. Xsprintf(pipe2, "ram:pipe2_%ld", Myprocess);
  940. X
  941. Xsprintf(buf,"%ld",Myprocess->pr_TaskNum);
  942. Xset_var(LEVEL_SET, "_clinumber", buf);
  943. X
  944. Xset_var(LEVEL_SET, v_titlebar, shellname);
  945. Xset_var(LEVEL_SET, v_prompt,
  946. X    (IsInteractive(Input())) ? "\23337m%p> \2330m" : "");
  947. Xset_var(LEVEL_SET, v_hist, "20");
  948. Xset_var(LEVEL_SET, v_lasterr, "0");
  949. Xset_var(LEVEL_SET, v_stat, "0");
  950. Xset_var(LEVEL_SET, v_path, "RAM:,RAM:c/,df0:c/,df1:c/,sys:system/");
  951. Xset_var(LEVEL_SET, "_insert", "1");
  952. Xset_var(LEVEL_SET, "f1", "cdir df0:\15");
  953. Xset_var(LEVEL_SET, "F1", "cdir df1:\15");
  954. Xset_var(LEVEL_SET, "f3", "cdir RAM:\15");
  955. Xset_var(LEVEL_SET, "F3", "cdir vd0:\15");
  956. Xset_var(LEVEL_SET, "f4", "cd df0:\15");
  957. Xset_var(LEVEL_SET, "F4", "cd df1:\15");
  958. Xset_var(LEVEL_SET, "f5", "cls; ls\15");
  959. Xset_var(LEVEL_SET, "F5", "cdir ");
  960. Xset_var(LEVEL_SET, "f6", "lc\15");
  961. Xset_var(LEVEL_SET, "f7", "info\15");
  962. Xset_var(LEVEL_SET, "F7", "assign \15");
  963. Xset_var(LEVEL_SET, "f8", "window -lf\15");
  964. Xset_var(LEVEL_SET, "F8", "window -sb\15");
  965. Xset_var(LEVEL_SET, "f10", "cls\15");
  966. Xset_var(LEVEL_SET, "F10", "exit\15");
  967. Xset_var(LEVEL_ALIAS, "cls", "echo -n ^l");
  968. Xset_var(LEVEL_ALIAS, "lc", "ls -s");
  969. Xset_var(LEVEL_ALIAS, "kr", "rm -r RAM:* >NIL:");
  970. Xset_var(LEVEL_ALIAS, "cdir", "%q cd $q; cls; dir");
  971. Xset_var(LEVEL_ALIAS, "exit", "endcli;quit");
  972. Xset_var(LEVEL_ALIAS, "lp", "cat >PRT:");
  973. Xseterr();
  974. Xif (Myprocess->pr_CurrentDir == NULL)
  975. X    do_cd("x :");
  976. Xelse do_pwd(NULL);
  977. XEnable_Abort = 0;
  978. X
  979. Xif (exists(av[1] = "S:.login")) do_source("x S:.login");
  980. X
  981. Xfor (i = 1; i < argc; ++i) {
  982. X    if (!strcmp(argv[i],"-c")) {
  983. X        Inline[0] = ' ';
  984. X        Inline[1] = '\0';
  985. X        while (++i < argc)
  986. X            { strcat(Inline,argv[i]); strcat(Inline," "); }
  987. X        exec_command(Inline);
  988. X        main_exit(Lastresult);
  989. X        }
  990. X    if (!strcmp(argv[i],"-a")) { aux = 1; continue; }
  991. X    sprintf (Inline, "source %s",argv[i]);
  992. X    av[1] = argv[i];
  993. X    do_source (Inline);
  994. X    }
  995. Xfor (;;) {
  996. X   if (breakcheck())
  997. X    while (WaitForChar(Input(), 100L) || stdin->_bp < stdin->_bend)
  998. X        gets(Inline);
  999. X   clearerr(stdin);  /* prevent acidental quit */
  1000. X#if RAW_CONSOLE
  1001. X   if (Quit || !rawgets(Inline, disable ? "_ " : trueprompt)) main_exit(0);
  1002. X#else
  1003. X   printf("%s", disable ? "_ " : trueprompt);
  1004. X   fflush(stdout);
  1005. X   if (Quit || !gets(Inline)) main_exit(0);
  1006. X#endif
  1007. X   breakreset();
  1008. X   if (*Inline) exec_command(Inline);
  1009. X   }
  1010. X}
  1011. X
  1012. Xmain_exit(n)
  1013. X{
  1014. Xregister unsigned short i;
  1015. Xchar buf[10];
  1016. X
  1017. XGetenv(shellctr,buf,10L);
  1018. Xi=(int)Atol(buf);
  1019. Xsprintf(buf,"%d",i-1);
  1020. XSetenv(shellctr,buf);
  1021. XSetWindowTitles(w,oldtitle,-1L);
  1022. Xfor (i=1; i<MAXMYFILES; i++) myclose((int)i);
  1023. XArpExit(0L,0L);            /* Intuition need not to be closed */
  1024. X}
  1025. X
  1026. Xbreakcheck()
  1027. X{
  1028. Xreturn (int)(SetSignal(0L,0L) & SIGBREAKF_CTRL_C);
  1029. X}
  1030. X
  1031. Xbreakreset()
  1032. X{
  1033. XSetSignal(0L, SIGBREAKF_CTRL_C);
  1034. X}
  1035. X
  1036. Xdobreak()
  1037. X{
  1038. Xif (breakcheck()) { printf("^C\n"); return(1); }
  1039. Xreturn(0);
  1040. X}
  1041. X
  1042. X/* this routine causes manx to use this Chk_Abort() rather than it's own */
  1043. X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */
  1044. X/* is zero).  Since we want to check for our own ^C's             */
  1045. X
  1046. XChk_Abort()
  1047. X{
  1048. Xreturn(0);
  1049. X}
  1050. X
  1051. X_wb_parse()
  1052. X{
  1053. X}
  1054. X
  1055. Xdo_howmany()
  1056. X{
  1057. Xchar buf[10];
  1058. X
  1059. XGetenv(shellctr, buf, 10L);
  1060. Xprintf("Shell(s) running: %s\n",buf);
  1061. X}
  1062. X
  1063. Xstruct Window *getwindow()
  1064. X{
  1065. Xstruct InfoData *infodata;
  1066. Xstruct Window *win;
  1067. Xlong args[8];
  1068. X
  1069. Xinfodata=AllocMem((long)sizeof(struct InfoData),MEMF_CLEAR | MEMF_PUBLIC);
  1070. Xargs[0]=(long)infodata >> 2;
  1071. XSendPacket(ACTION_DISK_INFO,args,Myprocess->pr_ConsoleTask);
  1072. Xwin=(struct Window *)infodata->id_VolumeNode;
  1073. XFreeMem(infodata,(long)sizeof(struct InfoData));
  1074. Xreturn win;
  1075. X}
  1076. END_OF_FILE
  1077. if test 4978 -ne `wc -c <'src/main.c'`; then
  1078.     echo shar: \"'src/main.c'\" unpacked with wrong size!
  1079. fi
  1080. # end of 'src/main.c'
  1081. fi
  1082. if test -f 'src/makefile' -a "${1}" != "-c" ; then 
  1083.   echo shar: Will not clobber existing file \"'src/makefile'\"
  1084. else
  1085. echo shar: Extracting \"'src/makefile'\" \(1019 characters\)
  1086. sed "s/^X//" >'src/makefile' <<'END_OF_FILE'
  1087. X######################################################################
  1088. X#
  1089. X# Makefile to build Shell 4.01A
  1090. X# by Carlo Borreo & Cesare Dieni 17-Feb-90
  1091. X#
  1092. X######################################################################
  1093. X
  1094. XOBJS    = run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o \
  1095. X      globals.o rawconsole.o
  1096. X
  1097. XINCL    = shell.h
  1098. X
  1099. XShell   : Shell.syms $(OBJS)
  1100. X    ln  +q -m -o Shell $(OBJS) -la -lc32
  1101. X
  1102. XShell.syms : $(INCL)
  1103. X    cc +L +HShell.syms shell.h -DAZTEC_C
  1104. X
  1105. Xrawconsole.o : rawconsole.c $(INCL)
  1106. X    cc +L +IShell.syms rawconsole.c
  1107. X
  1108. Xrun.o   : run.c $(INCL)
  1109. X    cc +L +IShell.syms run.c
  1110. X
  1111. Xmain.o  : main.c $(INCL)
  1112. X    cc +L +IShell.syms main.c
  1113. X
  1114. Xcomm1.o : comm1.c $(INCL)
  1115. X    cc +L +IShell.syms comm1.c
  1116. X
  1117. Xcomm2.o : comm2.c $(INCL)
  1118. X    cc +L +IShell.syms comm2.c
  1119. X
  1120. Xcomm3.o : comm3.c $(INCL)
  1121. X    cc +L +IShell.syms comm3.c
  1122. X
  1123. Xset.o   : set.c $(INCL)
  1124. X    cc +L +IShell.syms set.c
  1125. X
  1126. Xsub.o   : sub.c $(INCL)
  1127. X    cc +L +IShell.syms sub.c
  1128. X
  1129. Xglobals.o : globals.c $(INCL)
  1130. X    cc +L +IShell.syms globals.c
  1131. X
  1132. Xexecom.o : execom.c $(INCL)
  1133. X    cc +L +IShell.syms execom.c
  1134. END_OF_FILE
  1135. if test 1019 -ne `wc -c <'src/makefile'`; then
  1136.     echo shar: \"'src/makefile'\" unpacked with wrong size!
  1137. fi
  1138. # end of 'src/makefile'
  1139. fi
  1140. if test -f 'src/rawconsole.c' -a "${1}" != "-c" ; then 
  1141.   echo shar: Will not clobber existing file \"'src/rawconsole.c'\"
  1142. else
  1143. echo shar: Extracting \"'src/rawconsole.c'\" \(9156 characters\)
  1144. sed "s/^X//" >'src/rawconsole.c' <<'END_OF_FILE'
  1145. X/*
  1146. X * RawConsole.c
  1147. X *
  1148. X * Shell 2.07M  17-Jun-87
  1149. X * console handling, command line editing support for Shell
  1150. X * using new console packets from 1.2.
  1151. X * Written by Steve Drew. (c) 14-Oct-86.
  1152. X * 16-Dec-86 Slight mods to rawgets() for Disktrashing.
  1153. X *
  1154. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1155. X *
  1156. X */
  1157. X
  1158. X#if RAW_CONSOLE
  1159. X
  1160. Xchar *tyahdptr;
  1161. X
  1162. Xmyget()
  1163. X{
  1164. Xif (*tyahdptr) return *tyahdptr++;
  1165. Xreturn getchar();
  1166. X}
  1167. X
  1168. Xextern int aux; /* for use with aux: */
  1169. X
  1170. X#define SETRAW setrawcon(-1L);
  1171. X#define SETCON setrawcon(0L);
  1172. X
  1173. Xint width;
  1174. X
  1175. Xnewwidth()
  1176. X{
  1177. Xextern struct Window *w;
  1178. X
  1179. Xwidth=(w->Width- (w->BorderLeft + w->BorderRight)) / w->RPort->TxWidth;
  1180. X}
  1181. X
  1182. Xchar *rawgets(line,prompt)
  1183. Xchar *line, *prompt;
  1184. X{
  1185. Xchar *get_var();
  1186. Xchar *gets();
  1187. Xregister int n, pl;
  1188. Xregister int max, i;
  1189. Xunsigned char c1,c2,c3;
  1190. Xchar fkeys[5];
  1191. Xchar *s;
  1192. Xchar *ps;
  1193. Xchar typeahd[256];
  1194. Xint fkey, savn;
  1195. Xint insert = 1;
  1196. Xint recall = -1;
  1197. Xstruct HIST *hist;
  1198. X
  1199. Xnewwidth();
  1200. X
  1201. Xif (aux) {
  1202. X    printf("%s",prompt);
  1203. X    fflush(stdout);
  1204. X    }
  1205. Xif (!IsInteractive(Input()) || aux ) return(gets(line));
  1206. Xif (WaitForChar((long)Input(), 100L) ||   /* don't switch to 1L ...*/
  1207. X        stdin->_bp < stdin->_bend) {     /* else causes read err's*/
  1208. X    gets(line);
  1209. X    return(line);
  1210. X    }
  1211. XSETRAW;
  1212. Xprintf("\015%s\2336n",prompt);
  1213. Xsavn = pl = n = 0;
  1214. Xtyahdptr = typeahd;
  1215. Xwhile((typeahd[n]=getchar()) != 'R') {
  1216. X    if ((unsigned char)typeahd[n] == 155) savn = n;
  1217. X    n++;
  1218. X    }
  1219. X    /* typeahd now contains possible type a head chars
  1220. X       followed by <CSI> cursor position report.
  1221. X    */
  1222. Xtypeahd[savn]  = '\0';
  1223. Xif (typeahd[n-2] != ';') pl = (typeahd[n-2] - 48) * 10;
  1224. Xpl += typeahd[n-1] - 49;
  1225. Xps = line + pl;
  1226. Xline[max = i = pl] = '\0';
  1227. X
  1228. Xif (s = get_var (LEVEL_SET, "_insert")) insert = atoi(s) ? 1 : 0;
  1229. X
  1230. Xwhile( (c1 = myget()) != 255) {
  1231. X        switch(c1) {
  1232. X            case 155:
  1233. X                 c2 = myget();
  1234. X                 switch(c2) {
  1235. X                     case 'A':                  /* up arrow   */
  1236. X                        n = ++recall;
  1237. X                     case 'B':                  /* down arrow */
  1238. X                        line[pl] = '\0';
  1239. X                        if (recall >= 0 || c2 == 'A') {
  1240. X                            if (c2 == 'B') n = --recall;
  1241. X                            if (recall >= 0) {
  1242. X                                for(hist = H_head; hist && n--;
  1243. X                                    hist = hist->next);
  1244. X                                if (hist) strcpy(&line[pl],hist->line);
  1245. X                                else recall = H_len;
  1246. X                            }
  1247. X                        }
  1248. X                        if (i != pl)
  1249. X                            printf("\233%dD",i);
  1250. X                        printf("\015\233J%s%s",prompt,ps);
  1251. X                        i = max = strlen(ps) + pl;
  1252. X                        break;
  1253. X                     case 'C':                  /* right arrow*/
  1254. X                        if (i < max) {
  1255. X                            i++;
  1256. X                            printf("\233C");
  1257. X                        }
  1258. X                        break;
  1259. X                     case 'D':                  /* left arrow */
  1260. X                        if (i > pl) {
  1261. X                            i--;
  1262. X                            printf("\233D");
  1263. X                        }
  1264. X                        break;
  1265. X                     case 'T':           /* shift-up   */
  1266. X                       n = recall = H_len-1;
  1267. X                     case 'S':           /* shift-down */
  1268. X                       line[pl] = '\0';
  1269. X                       if (c2 == 'S') {
  1270. X                           n = recall = 0;
  1271. X                           if (H_head) strcpy(&line[pl], H_head->line);
  1272. X                       }
  1273. X                       else if (H_tail) strcpy(&line[pl], H_tail->line);
  1274. X                       printf("\015\233J%s%s", prompt, ps);
  1275. X                       i = max = strlen(ps) + pl;
  1276. X                       break;
  1277. X                    case ' ':                   /* shift -> <-*/
  1278. X                        c3 = myget();
  1279. X                                     switch(c3) {
  1280. X                    case('@'):      /* shift ->   */
  1281. X                        while (ps[i-pl-1] == ' ' && i<max) {
  1282. X                          i++;
  1283. X                          printf("\233C");
  1284. X                }
  1285. X                        while (ps[i-pl-1] != ' ' && i<max) {
  1286. X                          i++;
  1287. X                    printf("\233C");
  1288. X                       }
  1289. X                        break;
  1290. X                    case('A'):      /* shift <-   */
  1291. X                        while (ps[i-pl-1] == ' ' && i>pl) {
  1292. X                            i--;
  1293. X                            printf("\233D");
  1294. X                        }
  1295. X                        while (ps[i-pl-1] != ' ' && i>pl) {
  1296. X                            i--;
  1297. X                            printf("\233D");
  1298. X                        }
  1299. X                        break;
  1300. X                        default:
  1301. X                        break;
  1302. X                    }
  1303. X                        break;
  1304. X                    default:
  1305. X                        c3 = myget();
  1306. X                        if (c3 == '~') {
  1307. X                            fkey = c2;
  1308. X                            fkeys[0] = 'f';
  1309. X                            if (c2 == '?') {
  1310. X                                strcpy(ps,"help");
  1311. X                                goto done;
  1312. X                            }
  1313. X                        }
  1314. X                        else if (myget() != '~') { /* window was resized */
  1315. X                            while(myget() != '|');
  1316. X                            newwidth();
  1317. X                            break;
  1318. X                        }
  1319. X                        else {
  1320. X                            fkey = c3;
  1321. X                            fkeys[0] = 'F';
  1322. X                        }
  1323. X                        sprintf(fkeys+1,"%d",fkey - 47);
  1324. X                        if (s = get_var(LEVEL_SET, fkeys))
  1325. X                                tyahdptr = strcpy(typeahd,s);
  1326. X                        break;
  1327. X                    }
  1328. X                break;
  1329. X            case 8:
  1330. X                if (i > pl) {
  1331. X                    i--;
  1332. X                    printf("\010");
  1333. X                }
  1334. X                else break;
  1335. X            case 127:
  1336. X                if (i < max) {
  1337. X                    int j,t,l = 0;
  1338. X                    movmem(&line[i+1],&line[i],max-i);
  1339. X                    --max;
  1340. X                    printf("\233P");
  1341. X                    j = width - i % width - 1;   /* amount to end     */
  1342. X                    t = max/width - i/width;     /* no of lines       */
  1343. X                    for(n = 0; n < t; n++) {
  1344. X                        l += j;                  /* no. of char moved */
  1345. X                        if (j) printf("\233%dC",j); /* goto eol       */
  1346. X                        printf("%c\233P",line[width*(i/width+n+1)-1]);
  1347. X                        j = width-1;
  1348. X                    }
  1349. X                    if (t)
  1350. X                    printf("\233%dD",l+t);   /* get back */
  1351. X                }
  1352. X                break;
  1353. X            case 18:
  1354. X                n = i/width;
  1355. X                if (n) printf("\233%dF",n);
  1356. X                printf("\015\233J%s%s",prompt,ps);
  1357. X                i = max;
  1358. X                break;
  1359. X            case 27:
  1360. X                break;
  1361. X            case 1:
  1362. X                insert ^= 1;
  1363. X                break;
  1364. X            case 21:
  1365. X            case 24:
  1366. X            case 26:
  1367. X                if (i>pl) printf("\233%dD",i-pl);
  1368. X                i = pl;
  1369. X                if (c1 == 26) break;
  1370. X            case 11:        /* ^K */
  1371. X                printf("\233J");
  1372. X                max = i;
  1373. X                line[i] = '\0';
  1374. X                break;
  1375. X            case 28:        /* ^\ */
  1376. X                SETCON;
  1377. X                return(NULL);
  1378. X            case 5:
  1379. X                if (i!=max) printf("\233%dC",max - i);
  1380. X                i = max;
  1381. X                break;
  1382. X            case 10:
  1383. X            case 13:
  1384. X                line[max] = '\0';
  1385. Xdone:           printf("\233%dC\n",max - i);
  1386. X
  1387. X                SETCON;
  1388. X                strcpy(line, ps);
  1389. X                return(line);
  1390. X            default:
  1391. X                c1 &= 0x7f;
  1392. X                if (c1 == 9) c1 = 32;
  1393. X                if (c1 > 31 & i < 256) {
  1394. X                    if (i < max && insert) {
  1395. X                        int j,t,l = 0;
  1396. X                        movmem(&line[i], &line[i+1], max - i);
  1397. X                        printf("\233@%c",c1);
  1398. X                        t = max/width - i/width;
  1399. X                        j = width - i % width - 1;
  1400. X                        for(n = 0; n < t; n++) {
  1401. X                            l += j;
  1402. X                            if (j) printf("\233%dC",j);
  1403. X                            printf("\233@%c",line[width*(i/width+n+1)]);
  1404. X                            j = width-1;
  1405. X                        }
  1406. X                        if (t) printf("\233%dD",l + t);
  1407. X                        ++max;
  1408. X                    }
  1409. X                    else {
  1410. X                        if(i == pl && max == i) printf("\015%s%s",prompt,ps);
  1411. X                        putchar(c1);
  1412. X                    }
  1413. X                    line[i++] = c1;
  1414. X                    if (max < i) max = i;
  1415. X                    line[max] = '\0';
  1416. X                }
  1417. X        }
  1418. X    }
  1419. XSETCON;
  1420. Xreturn(NULL);
  1421. X}
  1422. X
  1423. Xsetrawcon(flag) /* -1L=RAW:, 0L=CON: */
  1424. Xlong flag;
  1425. X{
  1426. Xlong packargs[8];
  1427. X
  1428. Xpackargs[0]=flag;
  1429. XSendPacket(994L, packargs, Myprocess->pr_ConsoleTask);
  1430. X}
  1431. X
  1432. X#endif
  1433. END_OF_FILE
  1434. if test 9156 -ne `wc -c <'src/rawconsole.c'`; then
  1435.     echo shar: \"'src/rawconsole.c'\" unpacked with wrong size!
  1436. fi
  1437. # end of 'src/rawconsole.c'
  1438. fi
  1439. if test -f 'src/run.c' -a "${1}" != "-c" ; then 
  1440.   echo shar: Will not clobber existing file \"'src/run.c'\"
  1441. else
  1442. echo shar: Extracting \"'src/run.c'\" \(1712 characters\)
  1443. sed "s/^X//" >'src/run.c' <<'END_OF_FILE'
  1444. X
  1445. X/*
  1446. X * RUN.C
  1447. X *
  1448. X * (c)1986 Matthew Dillon     9 October 1986
  1449. X *
  1450. X *    RUN   handles running of external commands.
  1451. X *
  1452. X * Version 2.07M by Steve Drew 10-Sep-87
  1453. X *
  1454. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1455. X *
  1456. X */
  1457. X
  1458. Xchar *FindIt();
  1459. X
  1460. Xdo_run(str)
  1461. Xchar *str;
  1462. X{
  1463. Xint retcode;
  1464. Xchar buf[200]; /* enough space for 100 char cmd name + path stuff */
  1465. Xchar *path, *argline, *trueargline, *copy, *p = av[0];
  1466. X
  1467. Xwhile(*p++) *p &= 0x7F;      /* allow "com mand" */
  1468. X
  1469. Xargline=compile_av(av, 1, ac, ' ', 1);
  1470. Xtrueargline= (*argline ? argline : "\n");
  1471. X
  1472. Xif (strlen(av[0]) > 100) { ierror(NULL,509); return -1; }
  1473. X
  1474. Xsprintf(buf,"res_%s",BaseName(av[0]));
  1475. Xif (Getenv(buf, buf+100, 90L) && loadres(av[0])) Setenv(buf,NULL);
  1476. Xretcode=SyncRun(av[0],trueargline,0L,0L);
  1477. Xif (retcode>=0) { free(argline); return retcode; }
  1478. Xif (path = FindIt(av[0],"",buf)) {
  1479. X    retcode = SyncRun(path,trueargline,0L,0L);
  1480. X    free(argline);
  1481. X    return retcode;
  1482. X    }
  1483. Xelse free(argline);
  1484. Xif ((path = FindIt(av[0],".sh",buf)) == NULL) {
  1485. X    fprintf(stderr,"Command Not Found %s\n",av[0]);
  1486. X    return -1;
  1487. X    }
  1488. Xav[1] = buf;
  1489. Xcopy = malloc(strlen(str)+3);
  1490. Xsprintf(copy,"x %s",str);
  1491. Xretcode = do_source(copy);
  1492. Xfree(copy);
  1493. Xreturn retcode;
  1494. X}
  1495. X
  1496. Xchar *dofind(cmd, ext, buf)
  1497. Xchar *cmd, *ext, *buf;
  1498. X{
  1499. Xchar *ptr, *s;
  1500. X
  1501. Xsprintf(buf,"%s%s",cmd,ext);
  1502. Xif (exists(buf)) return buf;
  1503. Xif (BaseName(buf)==buf) {
  1504. X    s = get_var(LEVEL_SET, v_path);
  1505. X    while (*s) {
  1506. X        for (ptr=buf; *s && *s!=','; ) *ptr++ = *s++;
  1507. X        sprintf(ptr, "%s%s", cmd, ext);
  1508. X        if (exists(buf)) return buf;
  1509. X        if (*s) s++;
  1510. X        }
  1511. X    }
  1512. Xreturn NULL;
  1513. X}
  1514. X
  1515. Xchar *FindIt(cmd,ext,buf)
  1516. Xchar *cmd, *ext, *buf;
  1517. X{
  1518. Xchar *response;
  1519. X
  1520. XMyprocess->pr_WindowPtr = (APTR)(-1);
  1521. Xresponse=dofind(cmd,ext,buf);
  1522. XMyprocess->pr_WindowPtr = NULL;
  1523. Xreturn response;
  1524. X}
  1525. END_OF_FILE
  1526. if test 1712 -ne `wc -c <'src/run.c'`; then
  1527.     echo shar: \"'src/run.c'\" unpacked with wrong size!
  1528. fi
  1529. # end of 'src/run.c'
  1530. fi
  1531. if test -f 'src/set.c' -a "${1}" != "-c" ; then 
  1532.   echo shar: Will not clobber existing file \"'src/set.c'\"
  1533. else
  1534. echo shar: Extracting \"'src/set.c'\" \(3884 characters\)
  1535. sed "s/^X//" >'src/set.c' <<'END_OF_FILE'
  1536. X
  1537. X/*
  1538. X * SET.C
  1539. X *
  1540. X * (c)1986 Matthew Dillon     9 October 1986
  1541. X *
  1542. X * Version 2.07M by Steve Drew 10-Sep-87
  1543. X *
  1544. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1545. X *
  1546. X */
  1547. X
  1548. Xextern struct Window *w;
  1549. X
  1550. X#define MAXLEVELS (3 + MAXSRC)
  1551. X
  1552. Xstruct MASTER {
  1553. X    struct MASTER *next;
  1554. X    struct MASTER *last;
  1555. X    char *name;
  1556. X    char *text;
  1557. X};
  1558. X
  1559. Xstatic struct MASTER *Mbase[MAXLEVELS];
  1560. X
  1561. Xchar *set_var(level, name, str)
  1562. Xregister char *name, *str;
  1563. X{
  1564. X   register struct MASTER *base = Mbase[level];
  1565. X   register struct MASTER *last;
  1566. X   register int len;
  1567. X
  1568. X   for (len = 0; isalphanum(name[len]); ++len);
  1569. X   while (base != NULL) {
  1570. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) {
  1571. X         Free (base->text);
  1572. X         goto gotit;
  1573. X      }
  1574. X      last = base;
  1575. X      base = base->next;
  1576. X   }
  1577. X   if (base == Mbase[level]) {
  1578. X      base = Mbase[level] = (struct MASTER *)malloc (sizeof(struct MASTER));
  1579. X      base->last = NULL;
  1580. X   } else {
  1581. X      base = (struct MASTER *)malloc (sizeof(struct MASTER));
  1582. X      base->last = last;
  1583. X      last->next = base;
  1584. X   }
  1585. X   base->name = malloc (len + 1);
  1586. X   bmov (name, base->name, len);
  1587. X   base->name[len] = 0;
  1588. X   base->next = NULL;
  1589. Xgotit:
  1590. X   base->text = malloc (strlen(str) + 1);
  1591. X   strcpy (base->text, str);
  1592. X   if (*name=='_') sys_vars();
  1593. X   return (base->text);
  1594. X}
  1595. X
  1596. Xchar *get_var (level, name)
  1597. Xregister char *name;
  1598. X{
  1599. X   register struct MASTER *base = Mbase[level];
  1600. X   register unsigned char *scr;
  1601. X   register int len;
  1602. X
  1603. X   for (scr = (unsigned char *)name; *scr && *scr != 0x80 && *scr != ' ' && *scr != ';' && *scr != '|'; ++scr);
  1604. X   len = scr - name;
  1605. X
  1606. X   while (base != NULL) {
  1607. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0)
  1608. X         return (base->text);
  1609. X      base = base->next;
  1610. X   }
  1611. X   return (NULL);
  1612. X}
  1613. X
  1614. Xunset_level(level)
  1615. X{
  1616. X   register struct MASTER *base = Mbase[level];
  1617. X
  1618. X   while (base) {
  1619. X      Free (base->name);
  1620. X      Free (base->text);
  1621. X      Free (base);
  1622. X      base = base->next;
  1623. X   }
  1624. X   Mbase[level] = NULL;
  1625. X}
  1626. X
  1627. Xunset_var(level, name)
  1628. Xchar *name;
  1629. X{
  1630. X   register struct MASTER *base = Mbase[level];
  1631. X   register struct MASTER *last = NULL;
  1632. X   register int len;
  1633. X
  1634. X   for (len = 0; isalphanum(name[len]); ++len);
  1635. X   while (base) {
  1636. X      if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) {
  1637. X         if (base != Mbase[level])
  1638. X            last->next = base->next;
  1639. X         else
  1640. X            Mbase[level] = base->next;
  1641. X         if (base->next != NULL)
  1642. X            base->next->last = last;
  1643. X         if (base == Mbase[level])
  1644. X            Mbase[level] = base->next;
  1645. X         Free (base->name);
  1646. X         Free (base->text);
  1647. X         Free (base);
  1648. X         return (1);
  1649. X      }
  1650. X      last = base;
  1651. X      base = base->next;
  1652. X   }
  1653. X   return (-1);
  1654. X}
  1655. X
  1656. Xdo_unset_var(str, level)
  1657. Xchar *str;
  1658. X{
  1659. Xregister unsigned int i;
  1660. X
  1661. Xfor (i = 1; i < ac; ++i) unset_var (level, av[i]);
  1662. Xsys_vars();
  1663. Xreturn 0;
  1664. X}
  1665. X
  1666. Xdo_set_var(command, level)
  1667. Xchar *command;
  1668. X{
  1669. Xregister struct MASTER *base = Mbase[level];
  1670. Xregister char *str;
  1671. X
  1672. Xswitch (ac) {
  1673. Xcase 1:
  1674. X    while (base && !dobreak()) {
  1675. X        printf ("\2330m%-10s %s\n", base->name, base->text);
  1676. X        base = base->next;
  1677. X        }
  1678. X    break;
  1679. Xcase 2:
  1680. X    if (str=get_var(level,av[1])) printf ("%-10s %s\n", av[1], str);
  1681. X    break;
  1682. Xdefault:
  1683. X    set_var (level, av[1], next_word (next_word (command)));
  1684. X    if (*av[1]=='_') sys_vars();
  1685. X    break;
  1686. X    }
  1687. Xreturn 0;
  1688. X}
  1689. X
  1690. Xsys_vars()
  1691. X{
  1692. Xregister char *str, *t;
  1693. Xextern char trueprompt[100];
  1694. X
  1695. Xif (strcmp(w->Title, str=get_var(LEVEL_SET, v_titlebar)))
  1696. X    SetWindowTitles(w, str, -1L);
  1697. XS_histlen=(str = get_var(LEVEL_SET, v_hist)) ? atoi(str) : 0;
  1698. Xdebug  =(get_var(LEVEL_SET, v_debug)  !=NULL);
  1699. XVerbose=(get_var(LEVEL_SET, v_verbose)!=NULL);
  1700. Xif (S_histlen < 2) S_histlen=2;
  1701. X
  1702. Xif ( (str=get_var(LEVEL_SET,v_prompt)) ==NULL) str="$ ";
  1703. Xt=trueprompt;
  1704. Xwhile (*str)
  1705. X    if (*str=='%' && str[1]=='p') {
  1706. X        str+=2;
  1707. X        strcpy(t,get_var(LEVEL_SET, "_cwd"));
  1708. X        t+=strlen(t);
  1709. X        }
  1710. X    else *t++=*str++;
  1711. Xstrcpy(t,"\2330m");
  1712. X}
  1713. END_OF_FILE
  1714. if test 3884 -ne `wc -c <'src/set.c'`; then
  1715.     echo shar: \"'src/set.c'\" unpacked with wrong size!
  1716. fi
  1717. # end of 'src/set.c'
  1718. fi
  1719. if test -f 'src/shell.h' -a "${1}" != "-c" ; then 
  1720.   echo shar: Will not clobber existing file \"'src/shell.h'\"
  1721. else
  1722. echo shar: Extracting \"'src/shell.h'\" \(3029 characters\)
  1723. sed "s/^X//" >'src/shell.h' <<'END_OF_FILE'
  1724. X
  1725. X/*
  1726. X * SHELL.H
  1727. X *
  1728. X * (c)1986 Matthew Dillon     9 October 1986
  1729. X *
  1730. X *
  1731. X * SHELL include file.. contains shell parameters and extern's
  1732. X *
  1733. X * Version 2.07M by Steve Drew 10-Sep-87
  1734. X *
  1735. X * Version 4.01A by Carlo Borreo & Cesare Dieni 17-Feb-90
  1736. X *
  1737. X */
  1738. X
  1739. X#define RAW_CONSOLE 1   /* Set to 0 to compile out Cmd Line Editing */
  1740. X
  1741. X#include <stdio.h>
  1742. X#include <exec/exec.h>
  1743. X#include <time.h>
  1744. X#include <libraries/dos.h>
  1745. X#include <libraries/dosextens.h>
  1746. X#include <intuition/intuition.h>
  1747. X#include <intuition/intuitionbase.h>
  1748. X#include "shellfunctions.h"
  1749. X#include <fcntl.h>
  1750. X#include <libraries/arpbase.h>
  1751. X
  1752. Xtypedef struct FileInfoBlock FIB;
  1753. X
  1754. X#define bmov movmem
  1755. X
  1756. X#define MAXAV        256        /* Max. # arguments        */
  1757. X#define MAXSRC        5        /* Max. # of source file levels */
  1758. X#define MAXIF        10        /* Max. # of if levels        */
  1759. X#define MAXALIAS    20        /* Max. # of alias levels    */
  1760. X#define MAXMYFILES    9        /* Max. # of internal files    */
  1761. X
  1762. X#define LEVEL_SET    0        /* which variable list to use   */
  1763. X#define LEVEL_ALIAS    1
  1764. X#define LEVEL_LABEL    2
  1765. X
  1766. X    /* EXECOM.C defines */
  1767. X
  1768. X#define FL_DOLLAR    0x01  /* One of the following */
  1769. X#define FL_BANG        0x02
  1770. X#define FL_PERCENT    0x04
  1771. X#define FL_QUOTE    0x08
  1772. X#define FL_IDOLLAR    0x10  /* Any or all of the following may be set */
  1773. X#define FL_EOC        0x20
  1774. X#define FL_EOL        0x40
  1775. X#define FL_OVERIDE    0x80
  1776. X#define FL_WILD        0x100
  1777. X#define FL_MASK        (FL_DOLLAR|FL_BANG|FL_PERCENT|FL_QUOTE)
  1778. X
  1779. X#ifndef NULL
  1780. X#define NULL 0L
  1781. X#endif
  1782. X
  1783. X#define CHECKBREAK() dobreak()
  1784. X
  1785. X#ifndef AZTEC_C
  1786. Xstruct _dev {
  1787. X    long  fd;
  1788. X    short mode;
  1789. X    };
  1790. X#endif
  1791. X
  1792. Xstruct HIST {
  1793. X    struct HIST *next, *prev;    /* doubly linked list */
  1794. X    char *line;            /* line in history    */
  1795. X};
  1796. X
  1797. Xstruct PERROR {
  1798. X    int errnum;            /* Format of global error lookup */
  1799. X    char *errstr;
  1800. X};
  1801. X
  1802. Xstruct DPTR {                /* Format of directory fetch pointer */
  1803. X    BPTR lock;            /* lock on directory   */
  1804. X    FIB *fib;            /* mod'd fib for entry */
  1805. X    };
  1806. X
  1807. Xextern struct HIST *H_head, *H_tail;
  1808. Xextern struct PERROR Perror[];
  1809. Xextern struct DPTR *dopen();
  1810. Xextern char *set_var(), *get_var(), *next_word();
  1811. Xextern char *get_history(), *compile_av(), *get_pwd();
  1812. Xextern char *malloc(), *strcpy(), *strcat(), *index();
  1813. Xextern char **expand();
  1814. Xextern char *av[];
  1815. Xextern char *Current;
  1816. Xextern int  H_len, H_tail_base, H_stack;
  1817. Xextern int  E_stack;
  1818. Xextern int  Src_stack, If_stack, forward_goto;
  1819. Xextern int  ac;
  1820. Xextern int  debug, Rval, Verbose, disable, Quit;
  1821. Xextern int  Lastresult, atoierr;
  1822. Xextern int  Exec_abortline;
  1823. Xextern int   S_histlen;
  1824. Xextern unsigned int options;
  1825. Xextern long  Cin, Cout, Cout_append;
  1826. Xextern char *Cin_name, *Cout_name;
  1827. Xextern char  Cin_type,  Cout_type;  /* these variables are in transition */
  1828. Xextern char *Pipe1, *Pipe2;
  1829. X
  1830. Xextern long Src_base[MAXSRC];
  1831. Xextern long Src_pos[MAXSRC];
  1832. Xextern char If_base[MAXIF];
  1833. Xextern struct Process *Myprocess;
  1834. Xextern struct CommandLineInterface *Mycli;
  1835. X
  1836. Xextern struct ArpBase *ArpBase;
  1837. X
  1838. Xextern long atol(), Atol(), myatol();
  1839. X
  1840. Xextern char    v_titlebar[], v_prompt[], v_hist[], v_histnum[], v_debug[],
  1841. X        v_verbose[], v_stat[], v_lasterr[], v_cwd[], v_except[],
  1842. X        v_passed[], v_path[], v_gotofwd[], v_linenum[];
  1843. END_OF_FILE
  1844. if test 3029 -ne `wc -c <'src/shell.h'`; then
  1845.     echo shar: \"'src/shell.h'\" unpacked with wrong size!
  1846. fi
  1847. # end of 'src/shell.h'
  1848. fi
  1849. if test -f 'src/shellfunctions.h' -a "${1}" != "-c" ; then 
  1850.   echo shar: Will not clobber existing file \"'src/shellfunctions.h'\"
  1851. else
  1852. echo shar: Extracting \"'src/shellfunctions.h'\" \(9694 characters\)
  1853. sed "s/^X//" >'src/shellfunctions.h' <<'END_OF_FILE'
  1854. Xtypedef    long    cList;
  1855. Xextern int Enable_Abort;
  1856. X
  1857. Xlong                    AbleICR();
  1858. Xlong                    AbortIO();
  1859. Xlong                    ActivateGadget();
  1860. Xvoid                    ActivateWindow();
  1861. Xvoid                    AddAnimOb();
  1862. Xvoid                    AddBob();
  1863. Xvoid                    AddConfigDev();
  1864. Xvoid                    AddDevice();
  1865. Xlong                    AddDosNode();
  1866. Xvoid                    AddFont();
  1867. Xvoid                    AddFreeList();
  1868. Xshort                    AddGadget();
  1869. Xunsigned short                AddGList();
  1870. Xvoid                    AddHead();
  1871. Xstruct Interrupt *            AddICRVector();
  1872. Xvoid                    AddIntServer();
  1873. Xvoid                    AddLibrary();
  1874. Xlong                    AddMemList();
  1875. Xvoid                    AddPort();
  1876. Xvoid                    AddResource();
  1877. Xvoid                    AddSemaphore();
  1878. Xvoid                    AddTail();
  1879. Xvoid                    AddTask();
  1880. Xvoid                    AddTime();
  1881. Xvoid                    AddVSprite();
  1882. Xlong                    Alert();
  1883. Xvoid *                    AllocAbs();
  1884. Xlong                    AllocBoardMem();
  1885. XcList                    AllocCList();
  1886. Xstruct ConfigDev *            AllocConfigDev();
  1887. Xstruct MemList *            AllocEntry();
  1888. Xunsigned long                AllocExpansionMem();
  1889. Xvoid *                    AllocMem();
  1890. Xlong                    AllocPotBits();
  1891. Xvoid *                    AllocRaster();
  1892. Xchar *                    AllocRemember();
  1893. Xlong                    AllocSignal();
  1894. Xlong                    AllocTrap();
  1895. Xstruct WBObject *            AllocWBObject();
  1896. Xvoid *                    Allocate();
  1897. Xvoid                    AlohaWorkbench();
  1898. Xvoid                    AndRectRegion();
  1899. Xlong                    AndRegionRegion();
  1900. Xvoid                    Animate();
  1901. Xshort                    AreaDraw();
  1902. Xlong                    AreaEllipse();
  1903. Xvoid                    AreaEnd();
  1904. Xshort                    AreaMove();
  1905. Xvoid                    AskFont();
  1906. Xlong                    AskSoftStyle();
  1907. Xlong                    AttemptLockLayerRom();
  1908. Xlong                    AttemptSemaphore();
  1909. Xshort                    AutoRequest();
  1910. Xlong                    AvailFonts();
  1911. Xlong                    AvailMem();
  1912. Xvoid                    BeginIO();
  1913. Xvoid                    BeginRefresh();
  1914. Xvoid                    BeginUpdate();
  1915. Xvoid                    BeginLayer();
  1916. Xlong                    BltBitMap();
  1917. Xlong                    BltBitMapRastPort();
  1918. Xvoid                    BltClear();
  1919. Xvoid                    BltMaskBitMapRastPort();
  1920. Xvoid                    BltPattern();
  1921. Xvoid                    BltTemplate();
  1922. Xstruct Window *                BuildSysRequest();
  1923. Xchar *                    BumpRevision();
  1924. Xvoid                    Cause();
  1925. Xvoid                    CBump();
  1926. Xstruct Events *                CDInputHandler();
  1927. Xvoid                    ChangeSprite();
  1928. Xstruct IORequest *            CheckIO();
  1929. Xshort                    ClearDMRequest();
  1930. Xvoid                    ClearEOL();
  1931. Xvoid                    ClearMenuStrip();
  1932. Xvoid                    ClearPointer();
  1933. Xvoid                    ClearRegion();
  1934. Xlong                    ClearRectRegion();
  1935. Xvoid                    ClearScreen();
  1936. Xvoid                    ClipBit();
  1937. Xvoid                    Close();
  1938. Xvoid                    CloseDevice();
  1939. Xvoid                    CloseFont();
  1940. Xvoid                    CloseLibrary();
  1941. Xvoid                    CloseScreen();
  1942. Xvoid                    CloseWindow();
  1943. Xshort                    CloseWorkBench();
  1944. Xvoid                    CMove();
  1945. Xshort                    CmpTime();
  1946. Xlong                    ConcatCList();
  1947. Xlong                    ConfigBoard();
  1948. Xlong                    ConfigChain();
  1949. Xlong                    ConsoleDevice();
  1950. Xlong                    CopperListInit();
  1951. XcList                    CopyCList();
  1952. Xvoid                    CopyMem();
  1953. Xvoid                    CopyMemQuick();
  1954. Xvoid                    CopySBitMap();
  1955. Xstruct Layer *                CreateBehindLayer();
  1956. XBPTR        CreateDir();
  1957. Xstruct MsgPort *            CreatePort();
  1958. Xstruct Process *            CreateProc();
  1959. Xstruct IOStdReq *            CreateStdIO();
  1960. Xstruct Task *                CreateTask();
  1961. Xstruct Layer *                CreateUpfrontLayer();
  1962. XBPTR                    CurrentDir();
  1963. Xvoid                    CurrentTime();
  1964. Xvoid                    CWait();
  1965. Xlong *                    DateStamp();
  1966. Xvoid                    Deallocate();
  1967. Xvoid                    Debug();
  1968. Xvoid                    Delay();
  1969. Xshort                    DeleteFile();
  1970. Xvoid                    DeleteLayer();
  1971. Xvoid                    DeletePort();
  1972. Xvoid                    DeleteStdIO();
  1973. Xvoid                    DeleteTask();
  1974. Xstruct Process *            DeviceProc();
  1975. Xvoid                    Disable();
  1976. Xvoid                    DisownBlitter();
  1977. Xshort                    DisplayAlert();
  1978. Xvoid                    DisplayBeep();
  1979. Xvoid                    DisposeRegion();
  1980. Xvoid                    DoCollision();
  1981. Xlong                    DoIO();
  1982. Xshort                    DoubleClick();
  1983. Xvoid                    Draw();
  1984. Xvoid                    DrawBorder();
  1985. Xvoid                    DrawEllipse();
  1986. Xvoid                    DrawGList();
  1987. Xvoid                    DrawImage();
  1988. XBPTR                    DupLock();
  1989. Xvoid                    Enable();
  1990. Xvoid                    EndRefresh();
  1991. Xvoid                    EndRequest();
  1992. Xvoid                    EndUpdate();
  1993. Xvoid                    Enqueue();
  1994. Xshort                    ExNext();
  1995. Xshort                    Examine();
  1996. Xshort                    Execute();
  1997. Xvoid                    Exit();
  1998. Xstruct ConfigDev *            FindConfigDev();
  1999. Xstruct Node *                FindName();
  2000. Xstruct MsgPort *            FindPort();
  2001. Xstruct Resident *            FindResident();
  2002. Xstruct SignalSemaphore *        FindSemaphore();
  2003. Xstruct Task *                FindTask();
  2004. Xchar *                    FindToolType();
  2005. Xshort                    Flood();
  2006. Xvoid                    FlushCList();
  2007. Xvoid                    Forbid();
  2008. Xvoid                    FreeBoardMem();
  2009. Xvoid                    FreeCList();
  2010. Xvoid                    FreeColorMap();
  2011. Xvoid                    FreeConfigDev();
  2012. Xvoid                    FreeCopList();
  2013. Xvoid                    FreeCprList();
  2014. Xvoid                    FreeDiskObject();
  2015. Xvoid                    FreeEntry();
  2016. Xvoid                    FreeExpansionMem();
  2017. Xvoid                    FreeFreeList();
  2018. Xvoid                    FreeGBuffers();
  2019. Xvoid                    FreeMem();
  2020. Xvoid                    FreePotBits();
  2021. Xvoid                    FreeRaster();
  2022. Xvoid                    FreeRemember();
  2023. Xvoid                    FreeSignal();
  2024. Xvoid                    FreeSprite();
  2025. Xvoid                    FreeSysRequest();
  2026. Xvoid                    FreeTrap();
  2027. Xvoid                    FreeVPortCopLists();
  2028. Xvoid                    FreeWBObject();
  2029. Xlong                    GetCC();
  2030. Xlong                    GetCLBuf();
  2031. Xshort                    GetCLChar();
  2032. Xshort                    GetCLWord();
  2033. Xstruct ColorMap *            GetColorMap();
  2034. Xlong                    GetCurrentBinding();
  2035. Xstruct Preferences *            GetDefPrefs();
  2036. Xstruct DiskObject *            GetDiskObject();
  2037. Xshort                    GetGBuffers();
  2038. Xlong                    GetIcon();
  2039. Xstruct Message *            GetMsg();
  2040. Xstruct Preferences *            GetPrefs();
  2041. Xshort                    GetRGB4();
  2042. Xlong                    GetScreenData();
  2043. Xshort                    GetSprite();
  2044. Xstruct WBObject *            GetWBObject();
  2045. Xlong                    IncrCLMark();
  2046. Xshort                    Info();
  2047. Xvoid                    InitArea();
  2048. Xvoid                    InitBitMap();
  2049. Xlong                    InitCLPool();
  2050. Xvoid                    InitCode();
  2051. Xvoid                    InitGMasks();
  2052. Xvoid                    InitGels();
  2053. Xvoid                    InitMasks();
  2054. Xvoid                    InitRastPort();
  2055. Xvoid                    InitRequester();
  2056. Xvoid                    InitResident();
  2057. Xvoid                    InitSemaphore();
  2058. Xvoid                    InitStruct();
  2059. Xvoid                    InitTmpRas();
  2060. Xvoid                    InitVPort();
  2061. Xvoid                    InitView();
  2062. XBPTR                    Input();
  2063. Xvoid                    Insert();
  2064. Xstruct Region *                InstallClipRegion();
  2065. Xlong                    IntuiTextLength();
  2066. Xstruct InputEvent *            Intuition();
  2067. Xlong                    IoErr();
  2068. Xshort                    IsInteractive();
  2069. Xstruct MenuItem *            ItemAddress();
  2070. Xvoid                    LoadRGB4();
  2071. Xstruct Segment *            LoadSeg();
  2072. Xvoid                    LoadView();
  2073. XBPTR                    Lock();
  2074. Xvoid                    LockLayer();
  2075. Xvoid                    LockLayerInfo();
  2076. Xvoid                    LockLayerRom();
  2077. Xvoid                    LockLayers();
  2078. Xstruct DeviceNode *            MakeDosNode();
  2079. Xlong                    MakeFunctions();
  2080. Xstruct Library *            MakeLibrary();
  2081. Xvoid                    MakeScreen();
  2082. Xvoid                    MakeVPort();
  2083. Xlong                    MarkCList();
  2084. Xlong                    MatchToolValue();
  2085. Xvoid                    ModifyIDCMP();
  2086. Xvoid                    ModifyProp();
  2087. Xvoid                    Move();
  2088. Xlong                    MoveLayer();
  2089. Xvoid                    MoveScreen();
  2090. Xvoid                    MoveSprite();
  2091. Xvoid                    MoveWindow();
  2092. Xvoid                    MrgCop();
  2093. Xvoid                    NewList();
  2094. Xvoid                    NewModifyProp();
  2095. Xstruct Region *                NewRegion();
  2096. Xvoid                    ObtainConfigBinding();
  2097. Xvoid                    ObtainSemaphore();
  2098. Xvoid                    ObtainSemaphoreList();
  2099. Xvoid                    OffGadget();
  2100. Xvoid                    OffMenu();
  2101. Xvoid                    OnGadget();
  2102. Xvoid                    OnMenu();
  2103. XBPTR                    Open();
  2104. Xlong                    OpenDevice();
  2105. Xstruct Font *                OpenDiskFont();
  2106. Xstruct Font *                OpenFont();
  2107. Xvoid                    OpenIntuition();
  2108. Xstruct Library *            OpenLibrary();
  2109. Xstruct MiscResource *            OpenResource();
  2110. Xstruct Screen *                OpenScreen();
  2111. Xstruct Window *                OpenWindow();
  2112. Xshort                    OpenWorkBench();
  2113. Xvoid                    OrRectRegion();
  2114. Xlong                    OrRegionRegion();
  2115. XBPTR                    Output();
  2116. Xvoid                    OwnBlitter();
  2117. XBPTR                    ParentDir();
  2118. Xshort                    PeekCLMark();
  2119. Xvoid                    Permit();
  2120. Xvoid                    PolyDraw();
  2121. Xvoid                    PrintIText();
  2122. Xlong                    PutCLBuf();
  2123. Xlong                    PutCLChar();
  2124. Xlong                    PutCLWord();
  2125. Xshort                    PutDiskObject();
  2126. Xlong                    PutIcon();
  2127. Xvoid                    PutMsg();
  2128. Xlong                    PutWBObject();
  2129. Xvoid                    QBSBlit();
  2130. Xvoid                    QBlit();
  2131. Xshort                    RawKeyConvert();
  2132. Xlong                    Read();
  2133. Xchar                    ReadExpansionByte();
  2134. Xlong                    ReadExpansionRom();
  2135. Xshort                    ReadPixel();
  2136. Xvoid                    RectFill();
  2137. Xvoid                    RefreshGadgets();
  2138. Xvoid                    RefreshGList();
  2139. Xvoid                    RefreshWindowFrame();
  2140. Xvoid                    ReleaseConfigBinding();
  2141. Xvoid                    ReleaseSemaphore();
  2142. Xvoid                    ReleaseSemaphoreList();
  2143. Xvoid                    RemConfigDev();
  2144. Xlong                    RemDevice();
  2145. Xvoid                    RemFont();
  2146. Xstruct Node *                RemHead();
  2147. Xvoid                    RemIBob();
  2148. Xvoid                    RemICRVector();
  2149. Xvoid                    RemIntServer();
  2150. Xlong                    RemLibrary();
  2151. Xunsigned short                RemoveGList();
  2152. Xvoid                    RemPort();
  2153. Xvoid                    RemResource();
  2154. Xvoid                    RemSemaphore();
  2155. Xstruct Node *                RemTail();
  2156. Xvoid                    RemTask();
  2157. Xvoid                    RemVSprite();
  2158. Xvoid                    RemakeDisplay();
  2159. Xvoid                    Remove();
  2160. Xunsigned short                RemoveGadget();
  2161. Xshort                    Rename();
  2162. Xvoid                    ReplyMsg();
  2163. Xvoid                    ReportMouse();
  2164. Xshort                    Request();
  2165. Xvoid                    RethinkDisplay();
  2166. Xvoid                    ScreenToBack();
  2167. Xvoid                    ScreenToFront();
  2168. Xvoid                    ScrollLayer();
  2169. Xvoid                    ScrollRaster();
  2170. Xvoid                    ScrollVPort();
  2171. Xlong                    Seek();
  2172. Xvoid                    SendIO();
  2173. Xvoid                    SetAPen();
  2174. Xvoid                    SetBPen();
  2175. Xvoid                    SetCollision();
  2176. Xshort                    SetComment();
  2177. Xvoid                    SetCurrentBinding();
  2178. Xshort                    SetDMRequest();
  2179. Xvoid                    SetDRMd();
  2180. Xlong                    SetExcept();
  2181. Xlong                    SetFont();
  2182. Xlong                    SetFunction();
  2183. Xlong                    SetICR();
  2184. Xstruct Interrupt *            SetIntVector();
  2185. Xshort                    SetMenuStrip();
  2186. Xvoid                    SetPointer();
  2187. Xstruct Preferences *            SetPrefs();
  2188. Xshort                    SetProtection();
  2189. Xvoid                    SetRast();
  2190. Xvoid                    SetRGB4();
  2191. Xvoid                    SetRGB4CM();
  2192. Xlong                    SetSR();
  2193. Xlong                    SetSignal();
  2194. Xlong                    SetSoftStyle();
  2195. Xshort                    SetTaskPri();
  2196. Xvoid                    SetWindowTitles();
  2197. Xvoid                    ShowTitle();
  2198. Xvoid                    Signal();
  2199. Xlong                    SizeCList();
  2200. Xshort                    SizeLayer();
  2201. Xvoid                    SizeWindow();
  2202. Xvoid                    SortGList();
  2203. XcList                    SplitCList();
  2204. XcList                    SubCList();
  2205. Xvoid                    SubTime();
  2206. Xvoid                    SubLibrary();
  2207. Xvoid                    SumKickData();
  2208. Xlong                    SuperState();
  2209. Xvoid                    SwapBitsRastPortClipRect();
  2210. Xvoid                    SyncSBitMap();
  2211. Xlong                    Text();
  2212. Xlong                    TextLength();
  2213. Xlong                    Translate();
  2214. Xlong                    UnGetCLChar();
  2215. Xlong                    UnGetCLWord();
  2216. Xvoid                    UnLoadSeg();
  2217. Xvoid                    UnLock();
  2218. Xshort                    UnPutCLChar();
  2219. Xshort                    UnPutCLWord();
  2220. Xvoid                    UnlockLayer();
  2221. Xvoid                    UnlockLayerInfo();
  2222. Xvoid                    UnlockLayerRom();
  2223. Xvoid                    UnlockLayers();
  2224. Xshort                    UpfrontLayer();
  2225. Xvoid                    UserState();
  2226. Xshort                    VBeamPos();
  2227. Xstruct View *                ViewAddress();
  2228. Xstruct ViewPort *            ViewPortAddress();
  2229. Xshort                    WBenchToBack();
  2230. Xshort                    WBenchToFront();
  2231. Xlong                    Wait();
  2232. Xvoid                    WaitBOVP();
  2233. Xvoid                    WaitBlit();
  2234. Xshort                    WaitForChar();
  2235. Xlong                    WaitIO();
  2236. Xstruct Message *            WaitPort();
  2237. Xvoid                    WaitTOF();
  2238. Xstruct Layer *                WhichLayer();
  2239. Xshort                    WindowLimits();
  2240. Xvoid                    WindowToBack();
  2241. Xvoid                    WindowToFront();
  2242. Xlong                    Write();
  2243. Xlong                    WriteExpansionByte();
  2244. Xvoid                    WritePixel();
  2245. Xvoid                    WritePotgo();
  2246. Xvoid                    XorRectRegion();
  2247. Xlong                    XorRegionRegion();
  2248. END_OF_FILE
  2249. if test 9694 -ne `wc -c <'src/shellfunctions.h'`; then
  2250.     echo shar: \"'src/shellfunctions.h'\" unpacked with wrong size!
  2251. fi
  2252. # end of 'src/shellfunctions.h'
  2253. fi
  2254. echo shar: End of archive 1 \(of 4\).
  2255. cp /dev/null ark1isdone
  2256. MISSING=""
  2257. for I in 1 2 3 4 ; do
  2258.     if test ! -f ark${I}isdone ; then
  2259.     MISSING="${MISSING} ${I}"
  2260.     fi
  2261. done
  2262. if test "${MISSING}" = "" ; then
  2263.     echo You have unpacked all 4 archives.
  2264.     rm -f ark[1-9]isdone
  2265. else
  2266.     echo You still need to unpack the following archives:
  2267.     echo "        " ${MISSING}
  2268. fi
  2269. ##  End of shell archive.
  2270. exit 0
  2271. -- 
  2272. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  2273. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  2274. Post requests for sources, and general discussion to comp.sys.amiga.
  2275.